﻿<Window x:Class="WpfApplication1.Window3"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window3" Height="300" Width="300">
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="template1">
                <TextBox Text="t1"/>
            </DataTemplate>
            <DataTemplate x:Key="Template2">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="template2"/>
                    <ContentPresenter Grid.Row="1" Content="{Binding}" ContentTemplate="{StaticResource template1}"/>
                </Grid>
            </DataTemplate>
            <DataTemplate x:Key="Template3">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBlock Text="template3"/>
                    <ContentPresenter Grid.Row="1" Content="{Binding}" ContentTemplate="{StaticResource Template2}"/>
                </Grid>
            </DataTemplate>
        </Grid.Resources>
        <ContentPresenter ContentTemplate="{StaticResource template1}"/>
    </Grid>
</Window>
